package org.elepower.controller;

import org.apache.ibatis.annotations.Param;
import org.elepower.dao.InspectiontaskDetailsDao;
import org.elepower.dao.SystemConfigDao;
import org.elepower.pojo.PsSysteamconfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/bugEnter")
public class BugEnterController {
    @Autowired
    private InspectiontaskDetailsDao inspectiontaskDetailsDao;
    @Autowired
    private SystemConfigDao systemConfigDao;

    @RequestMapping("/index")
    public String index() throws Exception{
        return "system/bugEnter/index";
    }

    @RequestMapping("/enterBugLevel")
    @ResponseBody
    public Map<String,Object> enterBugLevel(@RequestParam("id") Integer id, @RequestParam("bugLevelId") Integer bugLevelId) throws Exception{
        Map<String,Object> map = new HashMap<>();
        //根据缺陷级别编号获取缺陷信息
        PsSysteamconfig systeamconfig = systemConfigDao.getBugLevelId(bugLevelId);
        System.out.println(id);
        System.out.println(bugLevelId);
        System.out.println(systeamconfig.getConfigValueName());
        //修改缺陷信息
        inspectiontaskDetailsDao.updateTaskIsBugLevel(id,bugLevelId,systeamconfig.getConfigValueName());
        map.put("result",true);
        return map;
    }
}
